package java学习.第05章_数组;

/**
 *
 *
 *
 */
public class E_二维数组 {
    public static void main(String[] args) {
        二维数组的了解();

    }

    private static void 二维数组的了解() {
        int[][] ints0 = new int[5][];//动态
        int[][] ints1 = new int[5][6];//动态
        int[][] ints2 = new int[][]{{1,2,3},{4,5,},{6,7,8,9,10},{11,12}};//静态
        int[] ints3[] = new int[5][6];//动态
        System.out.println(ints2[1][1]);

        //因为数组的二维没有大小，数组又是引用数组类型，所以是 null
        // 引用类型 默认null
        String[][] strings = new String[5][];
        System.out.println(strings[0]);//null
        String[][] strings1 = new String[5][6];
        System.out.println(strings1[0]);//[Ljava.lang.String;@776ec8df

        Integer[][][][] doubles3 = {{{{1,1,1},{2,2},{3},{4,4,4,4,4},{5,5,5},{6,666,6},{1,1,1},{2,2},{3},{4,4,4,4,4},{5,5,5},{6,666,6}}},{{{1,1,1},{2,2},{3},{4,4,4,4,4},{5,5,5},{6,666,6}},{{1,1,1},{2,2},{3},{4,4,4,4,4},{5,5,5},{6,666,6}}}};//动态
        System.out.println(doubles3[1]);

        Object o = doubles3;

        System.out.println("-------------");
        ss(o);
    }

    private static void ss(Object o){//无敌递归输出
        if(o instanceof Integer[]){
            Integer[] d = (Integer[]) o;
            for (int i = 0; i < d.length; i++) {
                System.out.print(d[i] + "-");
            }
            System.out.println();
        }else {
            System.out.println();
            Object[] os =(Object[]) o;
            for (int i = 0; i < os.length; i++) {
                ss(os[i]);
            }
        }
    }
}
/**
 * 5 + -6  = -1
 * 00000000
 * 00000101
 * 10000110
 *
 * 00000101
 *
 * 10000110
 * 11111001
 *
 * 11111010
 * 00000101
 *
 * 11111111
 * 11111110
 * 10000001
 *
 *
 *
 *
 */